package services.common;

import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Random;

import org.apache.commons.lang.StringUtils;

import com.itextpdf.text.pdf.PdfStructTreeController.returnType;
import com.mysql.jdbc.Buffer;
import com.zhongan.scorpoin.common.ZhongAnOpenException;

import common.constants.CacheKey;
import common.constants.Constants;
import common.constants.SettingKey;
import common.enums.AuditStatus;
import common.enums.Client;
import common.enums.CompanyInfoType;
import common.enums.IsBlackCompany;
import common.enums.IsCaCertificatePass;
import common.enums.IsCompany;
import common.enums.NoticeScene;
import common.enums.UserStatus;
import common.utils.DateUtil;
import common.utils.DeleteImg;
import common.utils.Factory;
import common.utils.JPAUtil;
import common.utils.LoggerUtil;
import common.utils.PageBean;
import common.utils.ReentrantLockUtil;
import common.utils.ResultInfo;
import common.utils.StrUtil;
import common.utils.number.Arith;
import daos.common.UserCertificationDao;
import daos.common.UserDao;
import daos.common.UserEventDao;
import models.common.bean.BondUser;
import models.common.bean.CompanyFundStatistic;
import models.common.bean.CurrUser;
import models.common.bean.ShowCompanyInfo;
import models.common.bean.ShowUserInfo;
import models.common.bean.UserDetail;
import models.common.bean.UserEventLog;
import models.common.bean.UserFundInfo;
import models.common.bean.UserFundStatistic;
import models.common.bean.UserRegistration;
import models.common.entity.t_bank_card_user;
import models.common.entity.t_company_info;
import models.common.entity.t_company_info_side;
import models.common.entity.t_event_supervisor;
import models.common.entity.t_event_user;
import models.common.entity.t_user;
import models.common.entity.t_user_certification;
import models.common.entity.t_user_fund;
import models.common.entity.t_user_info;
import models.common.entity.t_event_supervisor.Event;
import play.cache.Cache;
import play.db.jpa.JPAPlugin;
import play.mvc.Http.Request;
import play.mvc.Scope.Session;
import services.base.BaseService;

public class UserCertificationService extends BaseService<t_user_certification> {

	protected UserCertificationDao userDao = Factory.getDao(UserCertificationDao.class);
	
	protected static SupervisorService supervisorService = Factory.getService(SupervisorService.class);
	
	protected static UserInfoService userInfoService = Factory.getService(UserInfoService.class);

	protected static CompanyInfoService companyInfoService = Factory.getService(CompanyInfoService.class);
	
	protected UserCertificationService() {
		super.basedao = userDao;
	}
	/**
	 * 更新认证表信息
	 * @param t_user_certification
	 * @return
	 */
	public boolean saveUserCertification(String identificationTypeCode,String identificationNo,String issuerDn,String serialNumber,String subscriberName,long user_id,int status ){
		t_user_certification t = findByColumn(" user_id =?", user_id);
		if(null == t){
			t = new t_user_certification();
		}		
		t.certificate_type = identificationTypeCode;
		t.certification_status = status;
		t.full_name = subscriberName;
		t.id_number = identificationNo;
		t.time = new Date();
		t.user_id = user_id;
		t.issuerDn = issuerDn;
		t.serialNumber = serialNumber;
		return userDao.save(t);
	}

}
